package com.cmes.security;

import cn.dev33.satoken.exception.NotLoginException;
import com.cmes.core.ResponseCodeData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Servlet 全局异常处理
 *
 * @author Bruce.Gong
 * @since 1.0.0-SNAPSHOT
 */
@Slf4j
@RestControllerAdvice
public class SecurityExceptionHandler {

    /**
     * 全局异常处理
     */
    @ExceptionHandler(value = NotLoginException.class)
    public ResponseCodeData<?> loginException(NotLoginException e) {
        log.error("NotLoginException handler", e);
        return new ResponseCodeData<Void>().fail(e.getCode() + "", e.getMessage());
    }

}
